aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2015-09-02 06:50:54 +0200
committerMattias Andrée <maandree@operamail.com>2015-09-02 06:55:44 +0200
commit96f057488e31750a83b7e3a8cdd86effdce67fe0 (patch)
tree3e816a830761f1ed969b87389c264421d6b08d43 /Makefile
parentassert shall flush all streams (diff)
downloadslibc-96f057488e31750a83b7e3a8cdd86effdce67fe0.tar.gz
slibc-96f057488e31750a83b7e3a8cdd86effdce67fe0.tar.bz2
slibc-96f057488e31750a83b7e3a8cdd86effdce67fe0.tar.xz
automate some parts of intconf
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile34
1 files changed, 26 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index aaaf03b..50c156a 100644
--- a/Makefile
+++ b/Makefile
@@ -55,17 +55,22 @@ CCFLAGS_STATIC = $(CCFLAGS_COMMON)
CCFLAGS_SHARED = $(CCFLAGS_COMMON) -fPIC -DSHARED
# Flags required when genering header file dependency list.
-MMFLAGS = $(CCFLAGS_COMMON) -MG
+MMFLAGS = $(CCFLAGS_COMMON) -Igen -MG
+SHE = '\#'
+
# Object files to build.
-OBJECTS = $(shell find src | grep '\.c$$' | sed -e 's:^src/:obj/:' -e 's:\.c$$:\.o:')
+OBJECTS = $(shell find src | grep '\.c$$' | grep -v $(SHE) | sed -e 's:^src/:obj/:' -e 's:\.c$$:\.o:')
# All header files.
-HEADERS = $(shell find . | grep '\.h$$' | sed -e 's:^\./::')
+HEADERS = $(shell find . | grep '\.h$$' | grep -v $(SHE) | sed -e 's:^\./::')
# All code files.
-SOURCES = $(shell find src | grep '\.c$$')
+SOURCES = $(shell find src | grep '\.c$$' | grep -v $(SHE))
+
+# Generated headers files.
+GENERATED = include/bits/intconf.h
@@ -89,19 +94,31 @@ all: $(OBJECTS)
# Build object file.
-obj/%.o:
+obj/%.o: $(GENERATED)
@mkdir -p $$(dirname $@)
$(CC) -c -o $@ src/$*.c $(CCFLAGS_SHARED)
+# Preprocess header files.
+include/%.h: gen/%.h bin/gen/%
+ @mkdir -p $$(dirname $@)
+ gpp -s // < $< > $@
+
+bin/gen/%: obj/gen/%.o
+ @mkdir -p $$(dirname $@)
+ $(CC) $(CCFLAGS_WARNINGS) -std=c99 -o $@ $^
+obj/gen/%.o: gen/%.c
+ @mkdir -p $$(dirname $@)
+ $(CC) -c -o $@ $<
# Generate list of file dependencies for object files.
-obj/deps.mk: Makefile $(HEADERS) $(SOURCES)
+obj/deps.mk: Makefile $(HEADERS) $(SOURCES) $(GENERATED)
@mkdir -p obj
- @find src | grep '\.c$$' | xargs $(CC) -MM $(MMFLAGS) > $@
- @sed -i 's#^[^ :]*\.o: src\([^ ]*\)/[^ /]*\.c#obj\1/&#' $@
+ find src | grep '\.c$$' | xargs $(CC) -MM $(MMFLAGS) > $@
+ sed -i 's#^[^ :]*\.o: src\([^ ]*\)/[^ /]*\.c#obj\1/&#' $@
+ sed -i 's# gen/\([^ ]*\.h\)# \1#g' $@
@@ -109,6 +126,7 @@ obj/deps.mk: Makefile $(HEADERS) $(SOURCES)
.PHONY: clean
clean:
-rm -rf obj bin
+ -rm -f include/bits/intconf.h
# Remove all files that are not part of the source.
.PHONY: distclean