From 400c2b71b61b8897eb9d767dc043cfe100d2efd7 Mon Sep 17 00:00:00 2001 From: Zhu Qun-Ying Date: Sun, 11 Feb 2024 11:34:38 -0800 Subject: [PATCH] use meson build --- .gitignore | 4 +- GUI/xephem/Makefile | 7 +- GUI/xephem/meson.build | 9 ++ GUI/xephem/{xephem.man => xephem.1} | 0 XEphem.in | 2 + libastro/meson.build | 63 +++++++++++ libip/meson.build | 18 ++++ libjpegd/meson.build | 30 ++++++ liblilxml/meson.build | 6 ++ libpng/meson.build | 19 ++++ libz/meson.build | 15 +++ meson.build | 155 ++++++++++++++++++++++++++++ meson_options.txt | 4 + scripts/cppcheck.sh | 3 + xephem.desktop | 11 ++ 15 files changed, 338 insertions(+), 8 deletions(-) create mode 100644 GUI/xephem/meson.build rename GUI/xephem/{xephem.man => xephem.1} (100%) create mode 100644 XEphem.in create mode 100644 libastro/meson.build create mode 100644 libip/meson.build create mode 100644 libjpegd/meson.build create mode 100644 liblilxml/meson.build create mode 100644 libpng/meson.build create mode 100644 libz/meson.build create mode 100644 meson.build create mode 100644 meson_options.txt create mode 100755 scripts/cppcheck.sh create mode 100644 xephem.desktop diff --git a/.gitignore b/.gitignore index d5a9b6e..03b315d 100644 --- a/.gitignore +++ b/.gitignore @@ -3,8 +3,6 @@ *.a *.o /GUI/xephem/xephem -/GUI/xephem/xephem.1 - +.cache # macOS HFS+ files - ._* diff --git a/GUI/xephem/Makefile b/GUI/xephem/Makefile index 274269b..2256b71 100644 --- a/GUI/xephem/Makefile +++ b/GUI/xephem/Makefile @@ -197,14 +197,11 @@ OBJS = \ xephem.o \ xmisc.o -all: libs xephem xephem.1 +all: libs xephem xephem: $(INCS) $(OBJS) $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) -xephem.1: xephem.man - nroff -man $? > $@ - libs: cd ../../libastro; make cd ../../libip; make @@ -217,4 +214,4 @@ clean: rm -fr *.o ../../lib*/*.[ao] clobber: clean - rm -fr xephem xephem.1 + rm -fr xephem diff --git a/GUI/xephem/meson.build b/GUI/xephem/meson.build new file mode 100644 index 0000000..3445310 --- /dev/null +++ b/GUI/xephem/meson.build @@ -0,0 +1,9 @@ +install_man('xephem.1') +install_data('XEphem.png', install_dir: get_option('datadir') / 'pixmaps') +install_subdir('auxil', install_dir: xephem_data_dir, strip_directory : false) +install_subdir('catalogs', install_dir: xephem_data_dir, strip_directory : false) +install_subdir('fifos', install_dir: xephem_data_dir, strip_directory : false) +install_subdir('fits', install_dir: xephem_data_dir, strip_directory : false) +install_subdir('gallery', install_dir: xephem_data_dir, strip_directory : false) +install_subdir('help', install_dir: xephem_data_dir, strip_directory : false) +install_subdir('lo', install_dir: xephem_data_dir, strip_directory : false) diff --git a/GUI/xephem/xephem.man b/GUI/xephem/xephem.1 similarity index 100% rename from GUI/xephem/xephem.man rename to GUI/xephem/xephem.1 diff --git a/XEphem.in b/XEphem.in new file mode 100644 index 0000000..2350c84 --- /dev/null +++ b/XEphem.in @@ -0,0 +1,2 @@ +XEphem.ShareDir: @DATADIR@ +XEphem.PrivateDir: ~/.xephem diff --git a/libastro/meson.build b/libastro/meson.build new file mode 100644 index 0000000..b3b5df7 --- /dev/null +++ b/libastro/meson.build @@ -0,0 +1,63 @@ +libastro_src = [ + 'aa_hadec.c', + 'aberration.c', + 'actan.c', + 'airmass.c', + 'anomaly.c', + 'ap_as.c', + 'atlas.c', + 'auxil.c', + 'bdl.c', + 'chap95.c', + 'chap95_data.c', + 'circum.c', + 'comet.c', + 'constel.c', + 'dbfmt.c', + 'deep.c', + 'deltat.c', + 'earthsat.c', + 'eq_ecl.c', + 'eq_gal.c', + 'formats.c', + 'helio.c', + 'jupmoon.c', + 'libration.c', + 'magdecl.c', + 'marsmoon.c', + 'misc.c', + 'mjd.c', + 'moon.c', + 'mooncolong.c', + 'moonnf.c', + 'nutation.c', + 'obliq.c', + 'parallactic.c', + 'parallax.c', + 'plans.c', + 'plmoon.c', + 'plshadow.c', + 'precess.c', + 'reduce.c', + 'refract.c', + 'rings.c', + 'riset.c', + 'riset_cir.c', + 'satmoon.c', + 'sdp4.c', + 'sgp4.c', + 'sphcart.c', + 'sun.c', + 'thetag.c', + 'twobody.c', + 'umoon.c', + 'utc_gst.c', + 'vsop87.c', + 'vsop87_data.c', +] + +libastro_inc = include_directories('./') + +libastro = static_library('astro', libastro_src, + include_directories : libastro_inc) + diff --git a/libip/meson.build b/libip/meson.build new file mode 100644 index 0000000..d7b9ac2 --- /dev/null +++ b/libip/meson.build @@ -0,0 +1,18 @@ + +libip_src = [ + 'explodegif.c', + 'fits.c', + 'fsmatch.c', + 'gaussfit.c', + 'lstsqr.c', + 'median.c', + 'sqr.c', + 'stars.c', + 'stats.c', + 'walk.c', + 'wcs.c', +] + +libip_inc = include_directories('../libastro') +libip = static_library('ip', libip_src, + include_directories: libip_inc) diff --git a/libjpegd/meson.build b/libjpegd/meson.build new file mode 100644 index 0000000..956b916 --- /dev/null +++ b/libjpegd/meson.build @@ -0,0 +1,30 @@ +libjpegd_src = [ + 'jcomapi.c', + 'jdapimin.c', + 'jdapistd.c', + 'jdatasrc.c', + 'jdcoefct.c', + 'jdcolor.c', + 'jddctmgr.c', + 'jdhuff.c', + 'jdinput.c', + 'jdmainct.c', + 'jdmarker.c', + 'jdmaster.c', + 'jdmerge.c', + 'jdphuff.c', + 'jdpostct.c', + 'jdsample.c', + 'jerror.c', + 'jidctflt.c', + 'jidctfst.c', + 'jidctint.c', + 'jidctred.c', + 'jmemmgr.c', + 'jmemnobs.c', + 'jquant1.c', + 'jquant2.c', + 'jutils.c', +] + +libjpeg = static_library('jpegd', libjpegd_src) diff --git a/liblilxml/meson.build b/liblilxml/meson.build new file mode 100644 index 0000000..4ffe34c --- /dev/null +++ b/liblilxml/meson.build @@ -0,0 +1,6 @@ +liblilxml_src = [ + 'base64.c', + 'lilxml.c' +] + +liblilxml = static_library('lilxml', liblilxml_src) diff --git a/libpng/meson.build b/libpng/meson.build new file mode 100644 index 0000000..db4c865 --- /dev/null +++ b/libpng/meson.build @@ -0,0 +1,19 @@ +libpng_src = [ + 'png.c', + 'pngerror.c', + 'pngget.c', + 'pngmem.c', + 'pngpread.c', + 'pngread.c', + 'pngrio.c', + 'pngrtran.c', + 'pngrutil.c', + 'pngset.c', + 'pngtrans.c', + 'pngwio.c', + 'pngwrite.c', + 'pngwtran.c', + 'pngwutil.c', +] + +libpng = static_library('png', libpng_src) diff --git a/libz/meson.build b/libz/meson.build new file mode 100644 index 0000000..dabfdcb --- /dev/null +++ b/libz/meson.build @@ -0,0 +1,15 @@ +libz_src = [ + 'adler32.c', + 'compress.c', + 'crc32.c', + 'deflate.c', + 'inffast.c', + 'inflate.c', + 'inftrees.c', + 'testzlib.c', + 'trees.c', + 'uncompr.c', + 'zutil.c', +] + +libz = static_library('z', libz_src) diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..64e93bf --- /dev/null +++ b/meson.build @@ -0,0 +1,155 @@ +project('XEphem', 'c', + version : '4.1.0', + default_options : [ + 'warning_level=3', + 'b_lto=true', + 'optimization=2' + ]) + +inc_dirs = include_directories('libastro', 'libip', 'liblilxml') + +src=[ + 'GUI/xephem/aavso.c', + 'GUI/xephem/annotmenu.c', + 'GUI/xephem/broadcast.c', + 'GUI/xephem/calmenu.c', + 'GUI/xephem/closemenu.c', + 'GUI/xephem/compiler.c', + 'GUI/xephem/coordsmenu.c', + 'GUI/xephem/datamenu.c', + 'GUI/xephem/db.c', + 'GUI/xephem/dbmenu.c', + 'GUI/xephem/earthmap.c', + 'GUI/xephem/earthmenu.c', + 'GUI/xephem/fallbacks.c', + 'GUI/xephem/favmenu.c', + 'GUI/xephem/formats.c', + 'GUI/xephem/fsmenu.c', + 'GUI/xephem/gallerymenu.c', + 'GUI/xephem/glance.c', + 'GUI/xephem/gsc.c', + 'GUI/xephem/gscnet.c', + 'GUI/xephem/helpmenu.c', + 'GUI/xephem/homeio.c', + 'GUI/xephem/hznmenu.c', + 'GUI/xephem/imregmenu.c', + 'GUI/xephem/indimenu.c', + 'GUI/xephem/jpeg2pm.c', + 'GUI/xephem/jupmenu.c', + 'GUI/xephem/listmenu.c', + 'GUI/xephem/mainmenu.c', + 'GUI/xephem/marsmenu.c', + 'GUI/xephem/marsmmenu.c', + 'GUI/xephem/moonmenu.c', + 'GUI/xephem/moviemenu.c', + 'GUI/xephem/msgmenu.c', + 'GUI/xephem/netmenu.c', + 'GUI/xephem/objmenu.c', + 'GUI/xephem/obslog.c', + 'GUI/xephem/patchlevel.c', + 'GUI/xephem/plot_aux.c', + 'GUI/xephem/plotmenu.c', + 'GUI/xephem/preferences.c', + 'GUI/xephem/progress.c', + 'GUI/xephem/ps.c', + 'GUI/xephem/query.c', + 'GUI/xephem/rotated.c', + 'GUI/xephem/satmenu.c', + 'GUI/xephem/saveres.c', + 'GUI/xephem/scope.c', + 'GUI/xephem/sites.c', + 'GUI/xephem/skybinary.c', + 'GUI/xephem/skyeyep.c', + 'GUI/xephem/skyfifos.c', + 'GUI/xephem/skyfiltmenu.c', + 'GUI/xephem/skyfits.c', + 'GUI/xephem/skyhist.c', + 'GUI/xephem/skyip.c', + 'GUI/xephem/skylist.c', + 'GUI/xephem/skytoolbar.c', + 'GUI/xephem/skyviewmenu.c', + 'GUI/xephem/solsysmenu.c', + 'GUI/xephem/splash.c', + 'GUI/xephem/srchmenu.c', + 'GUI/xephem/sunmenu.c', + 'GUI/xephem/time.c', + 'GUI/xephem/tips.c', + 'GUI/xephem/trailmenu.c', + 'GUI/xephem/ucac.c', + 'GUI/xephem/uranusmenu.c', + 'GUI/xephem/usno.c', + 'GUI/xephem/versionmenu.c', + 'GUI/xephem/webdbmenu.c', + 'GUI/xephem/xe2.c', + 'GUI/xephem/xe3.c', + 'GUI/xephem/xephem.c', + 'GUI/xephem/xmisc.c', +] + +ccompiler = meson.get_compiler('c') + +empty_dep = dependency('', required:false) + +motif_dep = ccompiler.find_library('Xm') +xt_dep = ccompiler.find_library('Xt') +x_dep = dependency('X11') + +openssl_dep = dependency('openssl') +m_dep = ccompiler.find_library('m', required: false) +if m_dep.found() + add_project_link_arguments('-lm', language : 'c') + +if get_option('with-sys-zlib') + zlib_dep = dependency('zlib') + libz = [] + zlib_inc = [] +else + zlib_dep = empty_dep + subdir('libz') + zlib_inc = include_directories('libz') +endif + +if get_option('with-sys-jpeg') + jpeg_dep = dependency('libjpeg') + libjpeg = [] + jpeg_inc = [] +else + jpeg_dep = empty_dep + subdir('libjpegd') + jpeg_inc = include_directories('libjpegd') +endif + +if get_option('with-sys-png') + png_dep = dependency('libpng') + libpng = [] + png_inc = [] +else + png_dep = empty_dep + subdir('libpng') + png_inc = include_directories('libpng') +endif + +xephem_data_dir = get_option('datadir') / 'xephem' + +subdir('libastro') +subdir('libip') +subdir('liblilxml') +subdir('GUI/xephem') + +executable('xephem', src, + dependencies: [motif_dep, xt_dep, x_dep, zlib_dep, \ + jpeg_dep, png_dep, openssl_dep, m_dep], + include_directories: [inc_dirs, png_inc, zlib_inc, jpeg_inc], + link_with: [libastro, libip, liblilxml, libpng, libz, libjpeg], + install : true) +endif + +run_target('cppcheck', command:['scripts/cppcheck.sh', '--project=' + + join_paths(meson.build_root(), 'compile_commands.json')]) + +conf_data = configuration_data() +conf_data.set('DATADIR', get_option('prefix') / xephem_data_dir) +configure_file(input: 'XEphem.in', + output : 'XEphem', + configuration: conf_data, + install_dir : get_option('sysconfdir') / 'X11/app-defaults/') diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000..c2ee73e --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,4 @@ +option('with-sys-zlib', type: 'boolean', value: true) +option('with-sys-png', type: 'boolean', value: true) +option('with-sys-jpeg', type: 'boolean', value: true) + diff --git a/scripts/cppcheck.sh b/scripts/cppcheck.sh new file mode 100755 index 0000000..dad839a --- /dev/null +++ b/scripts/cppcheck.sh @@ -0,0 +1,3 @@ +#!/bin/sh +cppcheck --enable=all --inline-suppr --suppress=missingIncludeSystem \ +--cppcheck-build-dir=../build --inconclusive --library=posix $* diff --git a/xephem.desktop b/xephem.desktop new file mode 100644 index 0000000..f1088a6 --- /dev/null +++ b/xephem.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Version=1.0 +Exec=xephem +TryExec=xephem +Icon=XEphem +Terminal=false +Name=XEphem +GenericName=Astronomy program +Categories=Education;Science;Astronomy; +Type=Application +StartupNotify=false