aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--Makefile56
2 files changed, 43 insertions, 16 deletions
diff --git a/.gitignore b/.gitignore
index c6127b3..29a182b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -42,6 +42,9 @@
*.idb
*.pdb
+# Dep files
+.dep
+
# Kernel Module Compile Results
*.mod*
*.cmd
diff --git a/Makefile b/Makefile
index 4a815b0..6ac73b0 100644
--- a/Makefile
+++ b/Makefile
@@ -1,23 +1,22 @@
-PREFIX = /usr/local
-
VERSION = \"$(shell git describe --tags --dirty)\"
-CFLAGS = --std=c99 -pedantic -Wall -Werror -Os -I. -D_DEFAULT_SOURCE -DVERSION=${VERSION}
-all: opendeco opendeco_test libopendeco.a
+CC=gcc
+
+IFLAGS = -I.
+LFLAGS = -lm
-opendeco: src/opendeco.c src/deco.c src/deco.h src/schedule.c src/schedule.h src/output.c src/output.h src/opendeco-cli.h src/opendeco-cli.c src/opendeco-conf.h src/opendeco-conf.c toml/toml.c toml/toml.h
- $(CC) $(CFLAGS) src/opendeco.c src/deco.c src/schedule.c src/output.c src/opendeco-cli.c src/opendeco-conf.c toml/toml.c -lm -o opendeco
+CFLAGS = -Wall -Werror --std=c99 -pedantic $(IFLAGS) -D_DEFAULT_SOURCE -DVERSION=${VERSION}
+LDFLAGS = $(LFLAGS)
-opendeco_test: test/opendeco_test.c test/deco_test.c src/deco.c minunit/minunit.c minunit/minunit.h
- $(CC) $(CFLAGS) minunit/minunit.c test/opendeco_test.c test/deco_test.c src/deco.c -lm -o opendeco_test
+PREFIX = /usr/local
-libopendeco.a:
- $(CC) -c src/deco.c -o src/deco.o
- $(CC) -c src/schedule.c -o src/schedule.o
- $(CC) -c src/output.c -o src/output.o
- ar rs libopendeco.a src/deco.o src/schedule.o src/output.o
+OBJ_BIN = src/opendeco.o src/opendeco-cli.o src/opendeco-conf.o src/deco.o src/output.o src/schedule.o toml/toml.o
+OBJ_LIB = src/deco.o src/output.o src/schedule.o
+OBJ_TST = test/opendeco_test.o test/deco_test.o src/deco.o minunit/minunit.o
-lib: libopendeco.a
+DEPS = $(shell find -type f -name "*.dep")
+
+all: opendeco opendeco_test libopendeco.a
run: opendeco
./opendeco -d 30 -t 120 -g EAN32 --decogasses EAN50
@@ -25,7 +24,9 @@ run: opendeco
test: opendeco_test
./opendeco_test
-install: all
+lib: libopendeco.a
+
+install: opendeco
mkdir -p ${DESTDIR}${PREFIX}/bin
cp -f opendeco ${DESTDIR}${PREFIX}/bin
chmod 755 ${DESTDIR}${PREFIX}/bin/opendeco
@@ -33,8 +34,31 @@ install: all
uninstall:
rm -f ${DESTDIR}${PREFIX}/bin/opendeco
+opendeco: $(OBJ_BIN)
+ @echo " LD $@"
+ @$(CC) -o opendeco $(OBJ_BIN) $(LDFLAGS)
+
+opendeco_test: $(OBJ_TST)
+ @echo " LD $@"
+ @$(CC) -o opendeco_test $(OBJ_TST) $(LDFLAGS)
+
+libopendeco.a: $(OBJ_LIB)
+ @ar rs libopendeco.a $(OBJ_LIB)
+
+%.o: %.c
+ @echo " CC $@"
+ @mkdir -p .dep/$(dir $@)
+ @$(CC) $(CFLAGS) -MD -MF .dep/$@.dep -o $@ -c $<
+
clean:
+ rm -f $(OBJ_BIN)
+ rm -f $(OBJ_LIB)
+ rm -f $(OBJ_TST)
rm -f opendeco
rm -f opendeco_test
- rm -f src/*.o
rm -f libopendeco.a
+ rm -rf .dep
+
+-include $(DEPS)
+
+.PHONY: all run test lib install uninstall clean