fortrangoingonforty/fuss / 6105480

Browse files

stamping

Authored by espadonne
SHA
6105480e622487f66f64577f066307c6873e979a
Parents
b48c472
Tree
34de25b

4 changed files

StatusFile+-
M .gitignore 1 0
M Makefile 14 2
A VERSION 1 0
M src/fuss_main.f90 2 1
.gitignoremodified
@@ -1,2 +1,3 @@
11
 *.o
22
 fuss
3
+src/version_module.f90
Makefilemodified
@@ -4,9 +4,10 @@ FFLAGS = -O2 -Wall -ffree-line-length-none
44
 SRC_DIR = src
55
 BUILD_DIR = build
66
 BIN_DIR = .
7
+VERSION := $(shell cat VERSION 2>/dev/null || echo "unknown")
78
 
89
 # Module files (order matters for dependencies)
9
-MODULES = types_module.f90 cache_module.f90 terminal_module.f90 git_module.f90 tree_module.f90 display_module.f90
10
+MODULES = version_module.f90 types_module.f90 cache_module.f90 terminal_module.f90 git_module.f90 tree_module.f90 display_module.f90
1011
 MODULE_OBJS = $(MODULES:%.f90=$(BUILD_DIR)/%.o)
1112
 
1213
 # Main program
@@ -26,7 +27,18 @@ all: $(TARGET)
2627
 $(BUILD_DIR):
2728
 	mkdir -p $(BUILD_DIR)
2829
 
30
+# Generate version module before building
31
+$(SRC_DIR)/version_module.f90: VERSION
32
+	@echo "Generating version module..."
33
+	@echo "module version_module" > $@
34
+	@echo "    implicit none" >> $@
35
+	@echo "    character(len=*), parameter :: VERSION = '$(VERSION)'" >> $@
36
+	@echo "end module version_module" >> $@
37
+
2938
 # Build modules with explicit dependencies
39
+$(BUILD_DIR)/version_module.o: $(SRC_DIR)/version_module.f90 | $(BUILD_DIR)
40
+	$(FC) $(FFLAGS) -J$(BUILD_DIR) -c $< -o $@
41
+
3042
 $(BUILD_DIR)/types_module.o: $(SRC_DIR)/types_module.f90 | $(BUILD_DIR)
3143
 	$(FC) $(FFLAGS) -J$(BUILD_DIR) -c $< -o $@
3244
 
@@ -54,4 +66,4 @@ $(TARGET): $(MODULE_OBJS) $(MAIN_OBJ)
5466
 	$(FC) $(FFLAGS) -o $@ $^
5567
 
5668
 clean:
57
-	rm -rf $(BUILD_DIR) $(TARGET)
69
+	rm -rf $(BUILD_DIR) $(TARGET) $(SRC_DIR)/version_module.f90
VERSIONadded
@@ -0,0 +1,1 @@
1
+1.2.7
src/fuss_main.f90modified
@@ -1,5 +1,6 @@
11
 program fuss
22
     use iso_fortran_env, only: error_unit
3
+    use version_module
34
     use types_module
45
     use git_module
56
     use tree_module
@@ -72,7 +73,7 @@ contains
7273
     end subroutine parse_arguments
7374
 
7475
     subroutine print_version()
75
-        print '(A)', 'fuss v1.0.0'
76
+        print '(A,A)', 'fuss v', trim(VERSION)
7677
         print '(A)', ''
7778
         print '(A)', 'A git staging tool. Written in Fortran, for some reason.'
7879
         print '(A)', 'https://github.com/FortranGoingOnForty/fuss'