make files and linking: empty objs

To design static lib, I am composing a make file, after that entire static libs are linked together by upper level make file. In different folders the project is made up, using these folders every static lib is designed, then processed towards global lib folder. I n these folders I possess a make file, in this make file I am facing a problem. For clearance I have mentioned it sub-make file here. Problem is this first time when I operate these all identical sub make-files, we found wild card empty that lengthen objs produced and 8bytes size output static lib is empty. In case of operating make file again everything operates ok without any modification. Here is one make file: https://www.theengineeringprojects.com/2021/10/how-to-setup-c-environment.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#===== aliases =====
#--- compiler
CC=g++
CFLAGS=-g -Wall -ansi
LIBNAME:=kmath

#--- folders
MAINPATH:=../..
OBJDIR:= $(MAINPATH)/obj
LIBDIR:= $(MAINPATH)/lib
INCLUDES:= -I ../include -I ../kStd -I ../kRTLib

#--- aliases
LOCALOBJS:=$(wildcard *.o)

#--- directives
vpath %.h ../include

#--- 
.PHONY: all
all: $(LIBNAME).a

#--- build lib
$(LIBNAME).a: *.cpp
	@+echo
	@echo "---creating $(LIBNAME) lib---"
	$(CC) $(INCLUDES) $(CFLAGS) -c $?; \
	ar rcs lib$(LIBNAME).a $(LOCALOBJS); \
	ranlib lib$(LIBNAME).a; \
	mv $(LOCALOBJS) $(OBJDIR); \
	cp -p lib$(LIBNAME).a $(LIBDIR

Last edited on
Topic archived. No new replies allowed.