improve Makefiles

Sun, 01 Oct 2023 14:41:17 +0200

author
Mike Becker <universe@uap-core.de>
date
Sun, 01 Oct 2023 14:41:17 +0200
changeset 74
831928419249
parent 73
072fa3e165f0
child 75
c72b250866ab

improve Makefiles

Makefile file | annotate | diff | comparison | revisions
configure file | annotate | diff | comparison | revisions
make/cc.mk file | annotate | diff | comparison | revisions
make/project.xml file | annotate | diff | comparison | revisions
--- a/Makefile	Sun Sep 24 18:48:42 2023 +0200
+++ b/Makefile	Sun Oct 01 14:41:17 2023 +0200
@@ -28,25 +28,25 @@
 
 include config.mk
 
-SRC  = frontend.c
-SRC += c2html.c
-SRC += highlighter.c
-
-OBJ = $(SRC:%.c=build/%.o)
-
 all: build build/c2html
 	
-build/c2html: $(OBJ)
-	$(CC) -o $@ $^ $(LDFLAGS)
-	
-build/%.o: src/%.c
+build/c2html: build/frontend.o build/highlighter.o build/c2html.o
+	$(CC) -o $@ $(LDFLAGS) $^
+
+build/c2html.o: src/c2html.c src/c2html.h src/highlighter.h
+	$(CC) -o $@ $(CFLAGS) -c $<
+
+build/frontend.o: src/frontend.c src/c2html.h src/highlighter.h
+	$(CC) -o $@ $(CFLAGS) -c $<
+
+build/highlighter.o: src/highlighter.c src/highlighter.h
 	$(CC) -o $@ $(CFLAGS) -c $<
 
 build:
 	$(MKDIR) $@
 	
 check: all
-	cd test && $(MAKE)
+	cd test && $(MAKE) -s
 	
 clean:
 	$(RMDIR) build
--- a/configure	Sun Sep 24 18:48:42 2023 +0200
+++ b/configure	Sun Oct 01 14:41:17 2023 +0200
@@ -227,6 +227,28 @@
     echo no
     return 0
 }
+dependency_error_tools()
+{
+    printf "checking for tools... "
+    # dependency tools platform="unix"
+    while true
+    do
+        if notisplatform "unix"; then
+            break
+        fi
+        cat >> $TEMP_DIR/make.mk << __EOF__
+# Dependency: tools
+RMDIR=rm -fR
+MKDIR=mkdir -p
+
+__EOF__
+        echo yes
+        return 1
+    done
+
+    echo no
+    return 0
+}
 
 
 
@@ -249,11 +271,6 @@
             break
         fi
 
-        cat >> "$TEMP_DIR/make.mk" << __EOF__
-MKDIR=mkdir -p
-RMDIR=rm -fR
-
-__EOF__
         break
     done
     break
@@ -290,6 +307,10 @@
     DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED ucx "
     ERROR=1
 fi
+if dependency_error_tools; then
+    DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED tools "
+    ERROR=1
+fi
 
 # Features
 
--- a/make/cc.mk	Sun Sep 24 18:48:42 2023 +0200
+++ b/make/cc.mk	Sun Oct 01 14:41:17 2023 +0200
@@ -3,6 +3,6 @@
 #
 
 CFLAGS =
+LDFLAGS =
 DEBUG_CC_FLAGS = -g
 RELEASE_CC_FLAGS = -O3 -DNDEBUG
-LDFLAGS =
--- a/make/project.xml	Sun Sep 24 18:48:42 2023 +0200
+++ b/make/project.xml	Sun Oct 01 14:41:17 2023 +0200
@@ -2,8 +2,12 @@
 <project xmlns="http://unixwork.de/uwproj">
 	<dependency>
 		<lang>c</lang>
-		<make>MKDIR=mkdir -p</make>
-		<make>RMDIR=rm -fR</make>
+	</dependency>
+	<dependency name="tools" platform="unix">
+		<make>
+RMDIR=rm -fR
+MKDIR=mkdir -p
+		</make>
 	</dependency>
 	<dependency name="ucx">
 		<test>check_lib ucx cx/list.h</test>

mercurial