Skip to content

Commit 381d9cf

Browse files
committed
prep compile for all platforms
1 parent fa1287b commit 381d9cf

File tree

5 files changed

+38
-47
lines changed

5 files changed

+38
-47
lines changed

Makefile.common

+2-4
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@ SOURCES_CPP=airport.cpp coast_map.cpp collect_airports.cpp depth_map.cpp log_msg
99

1010
SOURCES_C= spng.c http_get.c
1111

12+
GRIB_TEST_OBJS=coast_map.o depth_map.o sub_exec.o grib.o create_snow_png.o spng.o http_get.o
13+
1214
# the c++ standard to use
1315
CXXSTD=-std=c++20
1416

1517
OPT=-O3
16-
17-
# e.g. -DNDEBUG
18-
DEBUG=
19-

Makefile.lin64

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
OBJDIR=./build/lin
2-
MYLIB=$(OBJDIR)/libsnow.a
32

43
include version.mak
54
include Makefile.common
@@ -8,6 +7,7 @@ TARGET=build/lin.xpl
87

98
HEADERS=$(wildcard *.h)
109
OBJECTS:=$(addprefix $(OBJDIR)/, $(SOURCES_CPP:.cpp=.o)) $(addprefix $(OBJDIR)/, $(SOURCES_C:.c=.o))
10+
GRIB_TEST_OBJS:=$(addprefix $(OBJDIR)/, $(GRIB_TEST_OBJS))
1111

1212
# all sources to the dep files
1313
DEPFILES=$(SOURCES_CPP:%.cpp=$(DEPDIR)/%.d) $(SOURCES_C:%.c=$(DEPDIR)/%.d)
@@ -30,7 +30,7 @@ COMPILE.cpp = $(CXX) $(CXXFLAGS) $(DEPFLAGS) -c
3030
COMPILE.c = $(CC) $(CFLAGS) $(DEPFLAGS) -c
3131

3232
LDFLAGS=-shared -rdynamic -nodefaultlibs -undefined_warning
33-
LIBS=$(MYLIB) -lcurl -lz
33+
LIBS=-lcurl -lz -lOpenGL
3434

3535
$(OBJDIR)/%.o: %.cpp $(DEPDIR)/%.d version.mak | $(DEPDIR)
3636
$(COMPILE.cpp) -o $@ $<
@@ -40,16 +40,13 @@ $(OBJDIR)/%.o: %.c $(DEPDIR)/%.d version.mak | $(DEPDIR)
4040

4141
all: $(TARGET) grib_test.lin
4242

43-
$(MYLIB): $(OBJECTS)
44-
ar cr $@ $^
45-
4643
XPL_DIR=/e/X-Plane-12-test
4744

48-
$(TARGET): $(MYLIB)
49-
$(LD) -o $(TARGET) $(OBJDIR)/xa-snow.o $(LIBS) $(LDFLAGS) -lcurl -lz
45+
$(TARGET): $(OBJECTS)
46+
$(LD) -o $(TARGET) $(LDFLAGS) $(OBJECTS) $(LIBS)
5047

51-
grib_test.lin: grib_test.cpp log_msg.cpp $(MYLIB)
52-
$(CXX) $(CXXFLAGS) -DLOCAL_DEBUGSTRING -o $@ grib_test.cpp log_msg.cpp $(LIBS)
48+
grib_test.lin: grib_test.cpp log_msg.cpp $(GRIB_TEST_OBJS)
49+
$(CXX) $(CXXFLAGS) -DLOCAL_DEBUGSTRING -o $@ grib_test.cpp log_msg.cpp $(GRIB_TEST_OBJS) $(LIBS)
5350

5451
$(DEPDIR): ; @mkdir -p $@
5552

Makefile.mac64

+19-26
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@ TARGET=build/mac.xpl
77
TARGET_arm=$(OBJDIR)/mac.xpl_arm
88
TARGET_x86=$(OBJDIR)/mac.xpl_x86
99

10-
MYLIB_arm=$(OBJDIR)/libsnow_arm.a
11-
MYLIB_x86=$(OBJDIR)/libsnow_x86.a
12-
1310
HEADERS=$(wildcard *.h)
1411
OBJECTS_arm:=$(addprefix $(OBJDIR)/, $(SOURCES_CPP:.cpp=.o_arm)) $(addprefix $(OBJDIR)/, $(SOURCES_C:.c=.o_arm))
1512
OBJECTS_x86=$(OBJECTS_arm:.o_arm=.o_x86)
13+
GRIB_TEST_OBJS_arm:=$(addprefix $(OBJDIR)/, $(GRIB_TEST_OBJS:.o=.o_arm))
14+
GRIB_TEST_OBJS_x86:=$(addprefix $(OBJDIR)/, $(GRIB_TEST_OBJS:.o=.o_x86))
1615

1716
# all sources to the dep files
1817
DEPFILES=$(SOURCES_CPP:%.cpp=$(DEPDIR)/%.d) $(SOURCES_C:%.c=$(DEPDIR)/%.d)
@@ -23,19 +22,19 @@ DEPFLAGS = -MT $@ -MMD -MP -MF $(DEPDIR)/$*.d
2322
# if we run this script on Linux we it's osxcross
2423
UNAME_S := $(shell uname -s)
2524
ifeq ($(UNAME_S),Darwin)
26-
CCx=clang -target x86_64-apple-macos11
27-
CCa=clang -target arm64-apple-macos11
25+
CCx=clang -target x86_64-apple-macos13
26+
CCa=clang -target arm64-apple-macos13
2827

29-
CXXx=clang++ -target x86_64-apple-macos11
30-
CXXa=clang++ -target arm64-apple-macos11
28+
CXXx=clang++ -target x86_64-apple-macos13
29+
CXXa=clang++ -target arm64-apple-macos13
3130
AR=ar
3231
else
3332
PATH:=/osxcross/target/bin:$(PATH)
34-
CCx=o64-clang -mmacosx-version-min=12.0
35-
CCa=oa64-clang -mmacosx-version-min=12.0
33+
CCx=o64-clang -mmacosx-version-min=13.0
34+
CCa=oa64-clang -mmacosx-version-min=13.0
3635

37-
CXXx=o64-clang++ -mmacosx-version-min=12.0
38-
CXXa=oa64-clang++ -mmacosx-version-min=12.0
36+
CXXx=o64-clang++ -mmacosx-version-min=13.0
37+
CXXa=oa64-clang++ -mmacosx-version-min=13.0
3938
AR=llvm-ar
4039
endif
4140

@@ -47,20 +46,14 @@ CXXFLAGS=$(CXXSTD) $(CFLAGS)
4746
LNFLAGS+=-dynamiclib -shared -rdynamic -fvisibility=hidden -Wl,-exported_symbols_list -Wl,linkscript.mac
4847

4948
# https://pewpewthespells.com/blog/static_and_dynamic_libraries.html
50-
LIBS= $(MYLIB) -F $(SDK)/Libraries/Mac -framework XPLM -lcurl -lz
49+
LIBS= -F $(SDK)/Libraries/Mac -framework XPLM -framework OpenGL -lcurl -lz
5150

5251
#test:
5352
# $(foreach var,$(.VARIABLES),$(info $(var) = $($(var))))
5453

5554
all: $(TARGET) grib_test.mac
5655
$(shell [ -d $(OBJDIR) ] || mkdir -p $(OBJDIR))
5756

58-
$(MYLIB_arm): $(OBJECTS_arm)
59-
$(AR) cr $@ $^
60-
61-
$(MYLIB_x86): $(OBJECTS_x86)
62-
$(AR) cr $@ $^
63-
6457
$(OBJDIR)/%.o_arm: %.cpp version.mak
6558
$(CXXa) $(CXXFLAGS) -o $@ -c $<
6659

@@ -73,20 +66,20 @@ $(OBJDIR)/%.o_arm: %.c version.mak
7366
$(OBJDIR)/%.o_x86: %.c version.mak
7467
$(CCx) $(CFLAGS) -o $@ -c $<
7568

76-
$(TARGET_arm): $(MYLIB_arm)
77-
$(CXXa) -o $@ $(OBJDIR)/xa-snow.o_arm $(MYLIB_arm) $(LNFLAGS) $(LIBS)
69+
$(TARGET_arm): $(OBJECTS_arm)
70+
$(CXXa) -o $@ $(OBJECTS_arm) $(LNFLAGS) $(LIBS)
7871

79-
$(TARGET_x86): $(MYLIB_x86)
80-
$(CXXx) -o $@ $(OBJDIR)/xa-snow.o_x86 $(MYLIB_x86) $(LNFLAGS) $(LIBS)
72+
$(TARGET_x86): $(OBJECTS_x86)
73+
$(CXXx) -o $@ $(OBJECTS_x86) $(LNFLAGS) $(LIBS)
8174

8275
$(TARGET): $(TARGET_arm) $(TARGET_x86)
8376
lipo -create -output $@ $(TARGET_arm) $(TARGET_x86)
8477

85-
$(OBJDIR)/grib_test.mac_arm: $(MYLIB_arm) grib_test.cpp log_msg.cpp
86-
$(CXXa) $(CXXFLAGS) -DLOCAL_DEBUGSTRING -o $@ grib_test.cpp log_msg.cpp $(MYLIB_arm) -lcurl -lz
78+
$(OBJDIR)/grib_test.mac_arm: $(GRIB_TEST_OBJS_arm) grib_test.cpp log_msg.cpp
79+
$(CXXa) $(CXXFLAGS) -DLOCAL_DEBUGSTRING -o $@ grib_test.cpp log_msg.cpp $(GRIB_TEST_OBJS_arm) -lcurl -lz
8780

88-
$(OBJDIR)/grib_test.mac_x86: $(MYLIB_x86) grib_test.cpp log_msg.cpp
89-
$(CXXx) $(CXXFLAGS) -DLOCAL_DEBUGSTRING -o $@ grib_test.cpp log_msg.cpp $(MYLIB_x86) -lcurl -lz
81+
$(OBJDIR)/grib_test.mac_x86: $(GRIB_TEST_OBJS_x86) grib_test.cpp log_msg.cpp
82+
$(CXXx) $(CXXFLAGS) -DLOCAL_DEBUGSTRING -o $@ grib_test.cpp log_msg.cpp $(GRIB_TEST_OBJS_x86) -lcurl -lz
9083

9184
grib_test.mac: $(OBJDIR)/grib_test.mac_arm $(OBJDIR)/grib_test.mac_x86
9285
lipo -create -output $@ $(OBJDIR)/grib_test.mac_arm $(OBJDIR)/grib_test.mac_x86

Makefile.mgw64

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
OBJDIR=./build/win
2-
MYLIB=$(OBJDIR)/libsnow.a
32

43
include version.mak
54
include Makefile.common
@@ -8,6 +7,7 @@ TARGET=build/win.xpl
87

98
HEADERS=$(wildcard *.h)
109
OBJECTS:=$(addprefix $(OBJDIR)/, $(SOURCES_CPP:.cpp=.o)) $(addprefix $(OBJDIR)/, $(SOURCES_C:.c=.o))
10+
GRIB_TEST_OBJS:=$(addprefix $(OBJDIR)/, $(GRIB_TEST_OBJS))
1111

1212
# all sources to the dep files
1313
DEPFILES=$(SOURCES_CPP:%.cpp=$(DEPDIR)/%.d) $(SOURCES_C:%.c=$(DEPDIR)/%.d)
@@ -30,7 +30,7 @@ COMPILE.cpp = $(CXX) $(CXXFLAGS) $(DEPFLAGS) -c
3030
COMPILE.c = $(CC) $(CFLAGS) $(DEPFLAGS) -c
3131

3232
LDFLAGS=-shared -static-libgcc -static -lpthread
33-
LIBS=$(MYLIB) -L$(SDK)/Libraries/Win -lXPLM_64 -lXPWidgets_64 -lwinhttp -lopengl32 -lz
33+
LIBS=-L$(SDK)/Libraries/Win -lXPLM_64 -lXPWidgets_64 -lwinhttp -lopengl32 -lz
3434

3535
$(OBJDIR)/%.o: %.cpp $(DEPDIR)/%.d version.mak | $(DEPDIR)
3636
$(COMPILE.cpp) -o $@ $<
@@ -40,17 +40,15 @@ $(OBJDIR)/%.o: %.c $(DEPDIR)/%.d version.mak | $(DEPDIR)
4040

4141
all: $(TARGET) grib_test.exe
4242

43-
$(MYLIB): $(OBJECTS)
44-
ar cr $@ $^
4543

4644
XPL_DIR=/e/X-Plane-12-test
4745

48-
$(TARGET): $(MYLIB)
49-
$(LD) -o $(TARGET) $(OBJDIR)/xa-snow.o $(LIBS) $(LDFLAGS)
46+
$(TARGET): $(OBJECTS)
47+
$(LD) -o $(TARGET) $(OBJECTS) $(LIBS) $(LDFLAGS)
5048
if [ -d $(XPL_DIR)/Resources/plugins/XA-snow ]; then cp -p build/win.xpl $(XPL_DIR)/Resources/plugins/XA-snow/.; fi
5149

52-
grib_test.exe: grib_test.cpp log_msg.cpp $(MYLIB)
53-
$(CXX) $(CXXFLAGS) -DLOCAL_DEBUGSTRING -o $@ grib_test.cpp log_msg.cpp $(MYLIB) -lwinhttp -lz
50+
grib_test.exe: grib_test.cpp log_msg.cpp $(GRIB_TEST_OBJS)
51+
$(CXX) $(CXXFLAGS) -DLOCAL_DEBUGSTRING -o $@ grib_test.cpp log_msg.cpp $(GRIB_TEST_OBJS) -lwinhttp -lz
5452

5553
$(DEPDIR): ; @mkdir -p $@
5654

map_layer.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@
3333
#include "XPLMMap.h"
3434
#include "XPLMGraphics.h"
3535

36+
#if APL == 1
37+
#define GL_SILENCE_DEPRECATION
38+
#include <OpenGL/gl.h>
39+
#else
3640
#include <GL/gl.h>
41+
#endif
3742

3843
#define RGBA(R,G,B) \
3944
((150 << 24) | (((B)&0xff) << 16) | (((G)&0xff) << 8) | ((R)&0xff))

0 commit comments

Comments
 (0)