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 @@
1
 *.o
1
 *.o
2
 fuss
2
 fuss
3
+src/version_module.f90
Makefilemodified
@@ -4,9 +4,10 @@ FFLAGS = -O2 -Wall -ffree-line-length-none
4
 SRC_DIR = src
4
 SRC_DIR = src
5
 BUILD_DIR = build
5
 BUILD_DIR = build
6
 BIN_DIR = .
6
 BIN_DIR = .
7
+VERSION := $(shell cat VERSION 2>/dev/null || echo "unknown")
7
 
8
 
8
 # Module files (order matters for dependencies)
9
 # 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
10
 MODULE_OBJS = $(MODULES:%.f90=$(BUILD_DIR)/%.o)
11
 MODULE_OBJS = $(MODULES:%.f90=$(BUILD_DIR)/%.o)
11
 
12
 
12
 # Main program
13
 # Main program
@@ -26,7 +27,18 @@ all: $(TARGET)
26
 $(BUILD_DIR):
27
 $(BUILD_DIR):
27
 	mkdir -p $(BUILD_DIR)
28
 	mkdir -p $(BUILD_DIR)
28
 
29
 
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
+
29
 # Build modules with explicit dependencies
38
 # 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
+
30
 $(BUILD_DIR)/types_module.o: $(SRC_DIR)/types_module.f90 | $(BUILD_DIR)
42
 $(BUILD_DIR)/types_module.o: $(SRC_DIR)/types_module.f90 | $(BUILD_DIR)
31
 	$(FC) $(FFLAGS) -J$(BUILD_DIR) -c $< -o $@
43
 	$(FC) $(FFLAGS) -J$(BUILD_DIR) -c $< -o $@
32
 
44
 
@@ -54,4 +66,4 @@ $(TARGET): $(MODULE_OBJS) $(MAIN_OBJ)
54
 	$(FC) $(FFLAGS) -o $@ $^
66
 	$(FC) $(FFLAGS) -o $@ $^
55
 
67
 
56
 clean:
68
 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 @@
1
 program fuss
1
 program fuss
2
     use iso_fortran_env, only: error_unit
2
     use iso_fortran_env, only: error_unit
3
+    use version_module
3
     use types_module
4
     use types_module
4
     use git_module
5
     use git_module
5
     use tree_module
6
     use tree_module
@@ -72,7 +73,7 @@ contains
72
     end subroutine parse_arguments
73
     end subroutine parse_arguments
73
 
74
 
74
     subroutine print_version()
75
     subroutine print_version()
75
-        print '(A)', 'fuss v1.0.0'
76
+        print '(A,A)', 'fuss v', trim(VERSION)
76
         print '(A)', ''
77
         print '(A)', ''
77
         print '(A)', 'A git staging tool. Written in Fortran, for some reason.'
78
         print '(A)', 'A git staging tool. Written in Fortran, for some reason.'
78
         print '(A)', 'https://github.com/FortranGoingOnForty/fuss'
79
         print '(A)', 'https://github.com/FortranGoingOnForty/fuss'