a-shell icon indicating copy to clipboard operation
a-shell copied to clipboard

Makefile doesn't work correctly

Open JazzSoft opened this issue 2 years ago • 12 comments

I have a makefile that generates library (.a file) and executables. It warns .a file doesn't exist and generates dummy .a file.

I've been using this makefile on macOS, Ubuntu and even iSH Alpine linux. But this doesn't work on a-shell.

JazzSoft avatar Oct 10 '21 22:10 JazzSoft

Hi, I would need more information about the makefile in question in order to understand and fix the behaviour you describe.

a-Shell uses BSD-make, which is slightly different from GNU-make. The latter is more common in standard distributions (including OSX).

holzschu avatar Oct 11 '21 06:10 holzschu

Thanks for your quick response. My makefile has been working fine with macOS which is BSD Unix.

JazzSoft avatar Oct 11 '21 13:10 JazzSoft

Even though MacOS is BSD Unix, their version of make is GNU make. For example on my mac:

% make --version
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
% which make
/Applications/Xcode.app/Contents/Developer/usr/bin/make

BSD make is relatively less common.

holzschu avatar Oct 11 '21 13:10 holzschu

It also works with Ubuntu, though. BTW, this is the error message. It warns and generates .a file. Then it continues to the next .cpp file which depends on .a file:

$ make ar -r libjazz.a ar: warning: creating libjazz.a clang++ -std=c++17 -Wno-narrowing -Wno-switch -Wno-register -Wno-writable-strings -Wno-pragma-once-outside-header -Wno-nonportable-include-path -o t libjazz.debug/main.cpp libjazz.a

And .a is created without compiling .cpp files. The file size is only 88 bytes.

$ ls -l *.a -rw-r--r-- 1 mobile mobile 88 Oct 11 10:02 libjazz.a

JazzSoft avatar Oct 11 '21 14:10 JazzSoft

I really like your a-shell because it's way faster than iSH which runs on x86 emulator. I really want to make it work so that I can do my development with my iPad only.

JazzSoft avatar Oct 11 '21 14:10 JazzSoft

Here I my mkefile (partial)

all: $(LIB).a t $(GTEST)test $(TOOLS)atan $(TOOLS)ctan $(TOOLS)SongFinder $(TOOLS)EnumWords $(TOOLS)SrtParser test .cpp.o: $(SRC) $(INC) $(CXX) $(OPT) -c -w -o $(<:.cpp=.o) $< $(LIB).a: $(SRC:.cpp=.o) $(SRC) $(INC) ar -r $(LIB).a $(SRC:.cpp=.o)

JazzSoft avatar Oct 11 '21 14:10 JazzSoft

It also works with Ubuntu, though.

Same, Ubuntu also has GNU make by default. When it is installed, BSD make is usually called bmake. Between the makefile and the error message, the variable rewriting rule $(SRC:.cpp=.o) did not work. It could be that $(SRC) was not defined earlier (maybe because the rule that defines it is not implemented in BSD make), or that the rewriting rule did not work.

holzschu avatar Oct 11 '21 14:10 holzschu

Thanks, @holzschu! I will modify my makefile.

Just a side note, I also tried .sh script file (with chmod 777) but that didn't work. I also create a file (without #!/bin/sh) and ". filename" but that didn't work either. Ctrl + C didn't work. I think other people reported these issues.

JazzSoft avatar Oct 11 '21 15:10 JazzSoft

From a quick test, the rewriting rule $(SRC:.cpp=.o) works in BSD make, so the question is: what is the value of $SRC? You could try adding echo $(SRC) and echo $(SRC:.cpp=.o) on two lines after the line that starts with $(LIB).a:, before the line that starts with ar -r $(LIB).a ....

Just a side note, I also tried .sh script file (with chmod 777) but that didn't work. I also create a file (without #!/bin/sh) and ". filename" but that didn't work either. Ctrl + C didn't work. I think other people reported these issues.

Making a shell script work is really difficult (I have tried several times, and failed each time). It's on the TODO list. Scripts written in Perl, Lua and Python do work.

holzschu avatar Oct 11 '21 15:10 holzschu

$(SRC) is defined as this:

SRC = $(wildcard .cpp) $(wildcard dic/.cpp) $(wildcard semi/.cpp) $(wildcard semi/dorian/.cpp) $(wildcard semi/savoy/.cpp) $(wildcard music/tritone/.cpp)

And "echo $(SRC)" was empty. So I guess "wildcard" may not be supported by BSD make.

JazzSoft avatar Oct 11 '21 16:10 JazzSoft

Following suffix rule worked:

.cpp.o: $(SRC) $(INC) $(CXX) $(OPT) -c -w -o $(<:.cpp=.o) $<

BTW, "netdb.h" is not found. Would "libsocket" be supported by a-shell?

./Socket.h:20:10: fatal error: 'netdb.h' file not found #include <netdb.h> ^~~~~~~~~ 1 error generated.

JazzSoft avatar Oct 11 '21 16:10 JazzSoft

WASI currently does not support sockets. Then again, I have already added file access to WASI, so I could add sockets. It will take some time (or I could switch to emscripten, which has more system functions).

holzschu avatar Oct 11 '21 17:10 holzschu