dolib.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010-2020 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
  4. *
  5. * StarPU is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU Lesser General Public License as published by
  7. * the Free Software Foundation; either version 2.1 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * StarPU is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. *
  14. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  15. */
  16. /* Wrapper to avoid msys' tendency to turn / into \ and : into ; */
  17. #include <stdio.h>
  18. #include <stdlib.h>
  19. #if defined(_WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__)
  20. #include <unistd.h>
  21. #endif
  22. int main(int argc, char *argv[])
  23. {
  24. char *prog, *arch, *def, *effective_version, *version, *lib;
  25. char s[1024];
  26. char name[64];
  27. int current, age, revision;
  28. if (argc != 7)
  29. {
  30. fprintf(stderr, "[dolib] bad number of arguments, expected %d, got %d\n", 7, argc);
  31. exit(EXIT_FAILURE);
  32. }
  33. prog = argv[1];
  34. arch = argv[2];
  35. def = argv[3];
  36. effective_version = argv[4];
  37. version = argv[5];
  38. lib = argv[6];
  39. if (sscanf(version, "%d:%d:%d", &current, &revision, &age) != 3)
  40. {
  41. fprintf(stderr, "version not formatted as current:revision:age (%s)\n", version);
  42. exit(EXIT_FAILURE);
  43. }
  44. _snprintf(name, sizeof(name), "libstarpu-%s-%d", effective_version, current - age);
  45. name[sizeof(name) - 1] = '\0';
  46. fprintf(stdout, "[dolib] using soname '%s'\n", name);
  47. _snprintf(s, sizeof(s), "\"%s\" /machine:%s /def:%s /name:%s /out:%s", prog, arch, def, name, lib);
  48. s[sizeof(s) - 1] = '\0';
  49. if (system(s))
  50. {
  51. fprintf(stderr, "%s failed\n", s);
  52. exit(EXIT_FAILURE);
  53. }
  54. exit(EXIT_SUCCESS);
  55. }